﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
    /// <summary>
    /// 类P_SYSPARA。
    /// </summary>
    [Serializable]
    public partial class P_SYSPARA
    {
        public P_SYSPARA()
        { }
        #region Model
        private string _sysid;
        private string _email_sendor;
        private string _email_server;
        private decimal? _email_port;
        private decimal? _email_need_smpt;
        private string _email_user;
        private string _email_pwd;
        /// <summary>
        /// 系统ID
        /// </summary>
        public string SYSID
        {
            set { _sysid = value; }
            get { return _sysid; }
        }
        /// <summary>
        /// 邮件_发件人
        /// </summary>
        public string EMAIL_SENDOR
        {
            set { _email_sendor = value; }
            get { return _email_sendor; }
        }
        /// <summary>
        /// 邮件_服务器
        /// </summary>
        public string EMAIL_SERVER
        {
            set { _email_server = value; }
            get { return _email_server; }
        }
        /// <summary>
        /// 邮件_服务器端口
        /// </summary>
        public decimal? EMAIL_PORT
        {
            set { _email_port = value; }
            get { return _email_port; }
        }
        /// <summary>
        /// 邮件_是否SMTP验证
        /// </summary>
        public decimal? EMAIL_NEED_SMPT
        {
            set { _email_need_smpt = value; }
            get { return _email_need_smpt; }
        }
        /// <summary>
        /// 邮件_发送账号
        /// </summary>
        public string EMAIL_USER
        {
            set { _email_user = value; }
            get { return _email_user; }
        }
        /// <summary>
        /// 邮件_账号密码
        /// </summary>
        public string EMAIL_PWD
        {
            set { _email_pwd = value; }
            get { return _email_pwd; }
        }
        #endregion Model


        #region  Method

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public P_SYSPARA(string SYSID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select SYSID,EMAIL_SENDOR,EMAIL_SERVER,EMAIL_PORT,EMAIL_NEED_SMPT,EMAIL_USER,EMAIL_PWD ");
            strSql.Append(" FROM P_SYSPARA ");
            strSql.Append(" where SYSID=:SYSID ");
            OracleParameter[] parameters = {
					new OracleParameter(":SYSID", OracleType.VarChar,50)};
            parameters[0].Value = SYSID;

            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SYSID"] != null && ds.Tables[0].Rows[0]["SYSID"].ToString() != "")
                {
                    this.SYSID = ds.Tables[0].Rows[0]["SYSID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_SENDOR"] != null && ds.Tables[0].Rows[0]["EMAIL_SENDOR"].ToString() != "")
                {
                    this.EMAIL_SENDOR = ds.Tables[0].Rows[0]["EMAIL_SENDOR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_SERVER"] != null && ds.Tables[0].Rows[0]["EMAIL_SERVER"].ToString() != "")
                {
                    this.EMAIL_SERVER = ds.Tables[0].Rows[0]["EMAIL_SERVER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_PORT"] != null && ds.Tables[0].Rows[0]["EMAIL_PORT"].ToString() != "")
                {
                    this.EMAIL_PORT = decimal.Parse(ds.Tables[0].Rows[0]["EMAIL_PORT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"] != null && ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"].ToString() != "")
                {
                    this.EMAIL_NEED_SMPT = decimal.Parse(ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EMAIL_USER"] != null && ds.Tables[0].Rows[0]["EMAIL_USER"].ToString() != "")
                {
                    this.EMAIL_USER = ds.Tables[0].Rows[0]["EMAIL_USER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_PWD"] != null && ds.Tables[0].Rows[0]["EMAIL_PWD"].ToString() != "")
                {
                    this.EMAIL_PWD = ds.Tables[0].Rows[0]["EMAIL_PWD"].ToString();
                }
            }
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string SYSID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from P_SYSPARA");
            strSql.Append(" where SYSID=:SYSID ");

            OracleParameter[] parameters = {
					new OracleParameter(":SYSID", OracleType.VarChar,50)};
            parameters[0].Value = SYSID;

            return DbHelperOra.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into P_SYSPARA (");
            strSql.Append("SYSID,EMAIL_SENDOR,EMAIL_SERVER,EMAIL_PORT,EMAIL_NEED_SMPT,EMAIL_USER,EMAIL_PWD)");
            strSql.Append(" values (");
            strSql.Append(":SYSID,:EMAIL_SENDOR,:EMAIL_SERVER,:EMAIL_PORT,:EMAIL_NEED_SMPT,:EMAIL_USER,:EMAIL_PWD)");
            OracleParameter[] parameters = {
					new OracleParameter(":SYSID", OracleType.VarChar,1),
					new OracleParameter(":EMAIL_SENDOR", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_SERVER", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_PORT", OracleType.Number,4),
					new OracleParameter(":EMAIL_NEED_SMPT", OracleType.Number,4),
					new OracleParameter(":EMAIL_USER", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_PWD", OracleType.VarChar,100)};
            parameters[0].Value = SYSID;
            parameters[1].Value = EMAIL_SENDOR;
            parameters[2].Value = EMAIL_SERVER;
            parameters[3].Value = EMAIL_PORT;
            parameters[4].Value = EMAIL_NEED_SMPT;
            parameters[5].Value = EMAIL_USER;
            parameters[6].Value = EMAIL_PWD;

            DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update P_SYSPARA set ");
            strSql.Append("EMAIL_SENDOR=:EMAIL_SENDOR,");
            strSql.Append("EMAIL_SERVER=:EMAIL_SERVER,");
            strSql.Append("EMAIL_PORT=:EMAIL_PORT,");
            strSql.Append("EMAIL_NEED_SMPT=:EMAIL_NEED_SMPT,");
            strSql.Append("EMAIL_USER=:EMAIL_USER,");
            strSql.Append("EMAIL_PWD=:EMAIL_PWD");
            strSql.Append(" where SYSID=:SYSID ");
            OracleParameter[] parameters = {
					new OracleParameter(":EMAIL_SENDOR", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_SERVER", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_PORT", OracleType.Number,4),
					new OracleParameter(":EMAIL_NEED_SMPT", OracleType.Number,4),
					new OracleParameter(":EMAIL_USER", OracleType.VarChar,100),
					new OracleParameter(":EMAIL_PWD", OracleType.VarChar,100),
					new OracleParameter(":SYSID", OracleType.VarChar,1)};
            parameters[0].Value = EMAIL_SENDOR;
            parameters[1].Value = EMAIL_SERVER;
            parameters[2].Value = EMAIL_PORT;
            parameters[3].Value = EMAIL_NEED_SMPT;
            parameters[4].Value = EMAIL_USER;
            parameters[5].Value = EMAIL_PWD;
            parameters[6].Value = SYSID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string SYSID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from P_SYSPARA ");
            strSql.Append(" where SYSID=:SYSID ");
            OracleParameter[] parameters = {
					new OracleParameter(":SYSID", OracleType.VarChar,50)};
            parameters[0].Value = SYSID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void GetModel(string SYSID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select SYSID,EMAIL_SENDOR,EMAIL_SERVER,EMAIL_PORT,EMAIL_NEED_SMPT,EMAIL_USER,EMAIL_PWD ");
            strSql.Append(" FROM P_SYSPARA ");
            strSql.Append(" where SYSID=:SYSID ");
            OracleParameter[] parameters = {
					new OracleParameter(":SYSID", OracleType.VarChar,50)};
            parameters[0].Value = SYSID;

            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SYSID"] != null && ds.Tables[0].Rows[0]["SYSID"].ToString() != "")
                {
                    this.SYSID = ds.Tables[0].Rows[0]["SYSID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_SENDOR"] != null && ds.Tables[0].Rows[0]["EMAIL_SENDOR"].ToString() != "")
                {
                    this.EMAIL_SENDOR = ds.Tables[0].Rows[0]["EMAIL_SENDOR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_SERVER"] != null && ds.Tables[0].Rows[0]["EMAIL_SERVER"].ToString() != "")
                {
                    this.EMAIL_SERVER = ds.Tables[0].Rows[0]["EMAIL_SERVER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_PORT"] != null && ds.Tables[0].Rows[0]["EMAIL_PORT"].ToString() != "")
                {
                    this.EMAIL_PORT = decimal.Parse(ds.Tables[0].Rows[0]["EMAIL_PORT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"] != null && ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"].ToString() != "")
                {
                    this.EMAIL_NEED_SMPT = decimal.Parse(ds.Tables[0].Rows[0]["EMAIL_NEED_SMPT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EMAIL_USER"] != null && ds.Tables[0].Rows[0]["EMAIL_USER"].ToString() != "")
                {
                    this.EMAIL_USER = ds.Tables[0].Rows[0]["EMAIL_USER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EMAIL_PWD"] != null && ds.Tables[0].Rows[0]["EMAIL_PWD"].ToString() != "")
                {
                    this.EMAIL_PWD = ds.Tables[0].Rows[0]["EMAIL_PWD"].ToString();
                }
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM P_SYSPARA ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        #endregion  Method
    }
}

